<%-- 
    Document   : dojo1
    Created on : 2008-11-28, 0:44:35
    Author     : kanghui
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<script type="text/javascript">
    var djConfig = {
        isDebug:false, parseOnLoad:false
    };
</script>
<style type="text/css">
    .testClass {
        background-color:red;
    }

</style>
 <style type="text/css">
            .log {
                top:600px;
                width:800px;
                height:auto;
                border:1px solid red  
            }
        </style>
<script src="http://192.168.1.175/dojo/dojo.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
     <div id="logInfo" class="log">

      </div>
        <script type="text/javascript">
                dojo.addOnLoad(function(){
                       var a = [1,2,3];
                       var newArray1 = dojo.filter([1,2,3],function(x){return x > 2})
                       var newMap = dojo.map(a,function(x){return x > 0; })
                       log(newArray1); 
                        log(newMap[0]);
                       log(newMap)
                       var b = ["a","1",2]
                       dojo.forEach(b,log);
                      var new1 = dojo.every([4,5,6],function(x){return x > 3});
                       log(new1);
                       //log(newArray2); 
                        var values = [5, 2, 3, 4], sum, i;
                        for(sum = 0, i = 0; i < values.length; sum += values[i++]);
                        var percents = new Array(values.length);
                        for(i = 0; i < values.length; percents[i] = values[i] / sum, ++i);
                        log(sum);
                        log(values);
                        log(percents);
                        log("-------------------------");
                  
                        var sum = values.reduce(function(a,b){log(a);log(b);log("==");return a+b;});
                        log(sum);
                        var percents = values.map(function(val){return val / sum;})
                       dojo.forEach(percents,function(a,b){
                        //console.log(a,b);
                       });
                       dojo.require("dojox.lang.functional");
                       var df = dojox.lang.functional;
                      var min2 = df.lambda("Math.min(a, b)");
                      alert(min2)
                      alert(min2(3,54))
                      sum = values.reduce(min2);
                      alert(sum)
                      // console.log(percents[1])
                });
                
                function log(str){
                       
                         dojo.byId('logInfo').innerHTML += str;
                         dojo.byId('logInfo').innerHTML += '<br/>';
                }

        </script>
      
    </body>
</html>
